const app = getApp();
Page({
    data: {
        list:[]
    },
    onLoad(options) {
        //console.log("组件初始化",options);
        this.getInfoReportList();
    },

    onShow(){
      this.getInfoReportList();
    },

    getInfoReportList() {
      var that = this;
      var userAccount = wx.getStorageSync('userAccount')
      if (!userAccount) {
        wx.showToast({
          icon: "none",
          title: '当前用户未绑定手机号！',
        })
        return;
      }
      wx.request({
        url: app.globalData.getInfoReportListUrl,
        data: {
          cWxId: userAccount,
          cPhone: userAccount
        },
        method: 'GET',
        header: {
          'content-type': 'application/json'
        },
        success: function (data2) {
          if (data2.statusCode == 200) {
            // 渲染列表数据
            const listData =  data2.data.data || [];
            that.setData({
              list:listData
            });
            if(listData.length===0){
              wx.showToast({
                icon: "none",
                title: '暂无数据，即将返回首页！',
              })
              setTimeout(function(){
                wx.navigateBack({
                  delta: 1
                });
              },2000)
            }
          }else{
            wx.showToast({
              icon: "none",
              title: '服务器异常，请稍后再试！',
            })
          }
        },
        fail: function (err) {
          console.log(err);
          wx.showToast({
            icon: "none",
            title: '服务器异常，请稍后再试！',
          })
        }
      })
    },

    clickHandle1(e) {
        //console.log('点击导航栏',e.detail);
        wx.navigateTo({
          url: '/pages/infoupdate/index?code='+e.detail.key
        })
    },
});
